define(['util', 'ajax'], function (util, ajax) {
    "use strict";


    var exports = {},
		ViewModel;

    ViewModel = function () {
        var self = this;

        self.name = ko.observable();
        self.value = ko.observable();


        self.save = function () {
            var form = {
                Name: self.name(),
                Value: self.value(),
            };

            ajax.post('Template', form).done(function (response) {
                if (response.id != '') {
                    window.location = '/template/show?id=' + response.id;
                }
            });
        };

        self.cancel = function () {
            window.location = "index";
        };
    };

    exports.exec = function (sectionId, model) {
        var viewModel = new ViewModel(model);
        ko.applyBindings(viewModel, document.getElementById(sectionId));
    };
    return exports;
});
